package com.ffws.media.api;

import com.ffws.base.model.RestResponse;
import com.ffws.media.model.dto.MediaFilesDto;
import com.ffws.media.service.MediaFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author JC
 * @description TODO
 * @Date 2023-9-4 16:48
 * @Version 1.0
 */
@RestController
@Api(value = "媒资文件的接口", tags = "媒资文件的接口")
public class MediaFileController {

    @Autowired
    private MediaFileService mediaFileService;

    @ApiOperation("检查文件是否存在")
    @RequestMapping(value = "/file/checkFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public RestResponse<Boolean> checkFile(@ApiParam("文件") @RequestPart("file") MultipartFile file) {
        return mediaFileService.checkFile(file);
    }

    @ApiOperation("上传图片")
    @RequestMapping(value = "/file/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public RestResponse<MediaFilesDto> uploadFile(@ApiParam("文件") @RequestPart("file") MultipartFile file) {
        return mediaFileService.uploadFile(file);
    }

}
